/**
 * @param {number[]} nums
 * @return {number}
 */
var missingNumber = function(nums) {
  let sum = 0;
  for(let i = 0; i < nums.length; i++) {
    sum += i;
    sum -= nums[i];
  }
  sum += nums.length;
  return sum;
};
let nums = [3,0,1];
console.log(missingNumber(nums));
nums = [0,1];
console.log(missingNumber(nums));
nums = [9,6,4,2,3,5,7,0,1];
console.log(missingNumber(nums));
nums = [0];
console.log(missingNumber(nums));
